//
//  CQSplicedTemplateKitBundle.m
//  TSDemoDemo
//
//  Created by ciyouzen on 2017/2/25.
//  Copyright © 2017年 dvlproad. All rights reserved.
//

#import "CQSplicedTemplateKitBundle.h"

@implementation CQSplicedTemplateKitBundle

+ (nullable UIImage *)imageNamed:(NSString *)name {
    if(name && ![name isEqualToString:@""]) {
//        NSString *imageName = [NSString stringWithFormat:@"CQDemoKit.bundle/%@", name];
//        UIImage *image = [UIImage imageNamed:imageName];
        NSBundle *currentPodBundle = [self currentPodBundle];
        UIImage *image = [UIImage imageNamed:name inBundle:currentPodBundle compatibleWithTraitCollection:nil];
        return image;
    }
    
    return nil;
}

+ (NSString *)filePathWithFileName:(NSString *)fileName {
    NSBundle *currentPodBundle = [self currentPodBundle];
    NSString *filePath = [currentPodBundle.resourcePath stringByAppendingPathComponent:fileName];
    return filePath;
}

+ (NSBundle *)currentPodBundle {
    NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"CQSplicedTemplateKitBundle")];
    NSURL *url = [bundle URLForResource:@"CQSplicedTemplateKit" withExtension:@"bundle"];
    if(!url) return [UIImage new];
    NSBundle *currentPodBundle = [NSBundle bundleWithURL:url];
    return currentPodBundle;
}

@end
